package masterlink.sarPoint.util;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
public class MyQueue <E extends Comparable<?>> extends LinkedBlockingQueue<E>{
    public MyQueue(int a) {
        super(a);
    }	
    public MyQueue(){
        
    }
    public boolean add(E e) {
        if(remainingCapacity()==0){
            poll();
        }
        return super.add(e);
    }
	
    @SuppressWarnings("unchecked")
    public E max(){
        Object [] array=toArray();
        Arrays.sort(array);
        return (E) array[array.length-1];
    }
	
    @SuppressWarnings("unchecked")
    public E min(){
        Object [] array=toArray();
        Arrays.sort(array);
        return (E) array[0];
    }
}
